package com.chatSystem;

import javax.swing.*;

import java.awt.*;

import static com.chatSystem.Server.*;

public class state {
    static boolean xuanOnLine = false;
    static boolean taoOnLine = false;
    static boolean yuanOnLine =  false;
    static JButton xuan = new JButton("xuan");
    static JButton tao = new JButton("tao");
    static JButton yuan = new JButton("yuan");

    public static void main(String[] args) {
        new state();
        while(true){
            xuanOnLine = isXuanOnLine();
            taoOnLine = isTaoOnLine();
            yuanOnLine = isYuanOnLine();
            if(xuanOnLine){
                xuan.setEnabled(true);
            }
            if(xuanOnLine == false){
                xuan.setEnabled(false);
            }
            if(taoOnLine){
                tao.setEnabled(true);
            }
            if(taoOnLine == false){
                tao.setEnabled(false);
            }
            if(yuanOnLine){
                yuan.setEnabled(true);
            }
            if(yuanOnLine == false){
                yuan.setEnabled(false);
            }
        }
    }

    public static boolean xuanState(){
        return xuanOnLine;
    }
    public static boolean taoState(){
        return taoOnLine;
    }
    public static boolean yuanState(){
        return yuanOnLine;
    }
    void init(){

        JFrame stateFrame = new JFrame("用户状态指示器");
        JPanel statePanel = new JPanel();
        stateFrame.setVisible(true);
        stateFrame.setBounds(50,50,300,300);
        stateFrame.setDefaultCloseOperation(3);
        xuan.setEnabled(false);
        tao.setEnabled(false);
        yuan.setEnabled(false);
        statePanel.add(xuan, BorderLayout.NORTH);
        statePanel.add(tao,BorderLayout.CENTER);
        statePanel.add(yuan,BorderLayout.SOUTH);
        stateFrame.add(statePanel);
    }
    public state(){
        init();
    }

}
